<?php include "classes.inc" ?>
<?php include "constants.inc" ?>
<?php

  if (isset($_GET['match'])) {
    $userInput = $_GET['match'];
  }

  $connection = mysql_connect(DB_SERVER, DB_USER, DB_PWD);
	mysql_select_db(DB_CATALOG);
  $result = mysql_query("SELECT round_nr from zt_round", $connection);
  $resultTypeItems = array();
	while ($row = mysql_fetch_assoc($result)) {
    if ( isset($userInput) && !empty($userInput) ) {
      if (substr_compare($row['round_nr'], $userInput, 0, 1) === 0) {
        $keys[] = $row['round_nr'];
        $values[] = $row['round_nr'];
        $resultTypeItems = array_combine($keys, $values);
    	}
    } else {
      $keys[] = $row['round_nr'];
      $values[] = $row['round_nr'];
      $resultTypeItems = array_combine($keys, $values);
    }
	}

  echo json_encode($resultTypeItems);
?>